<%@ page import="java.util.List" %>
<%@ page import="com.po.InBox" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    List<InBox> myNote = (List<InBox>) request.getAttribute("myNote");
%>
<a href="<%=request.getContextPath()%>/success.jsp">返回总页面</a>
<br>
<div style="text-align: center">
    <h3>收件箱</h3>
</div>
<hr>
<%
    if (myNote.isEmpty()) {
%>
<div style="text-align: center">
    <a href="<%=request.getContextPath()%>/success.jsp">对不起你还没有邮件,返回总页面</a>
</div>
<%
} else {
    for (InBox inbox : myNote) {
        if ("add".equals(inbox.getWay())) {
%>
<div style="text-align: center">
    <%=inbox.getName()%><%=inbox.getSex()%>:想添加你为好友<br>
    <a href="">查看其个人信息</a>
    <input name="accept" value="同意"
           onclick="acc();window.location.href='<%=request.getContextPath()%>/requestAdd?state=accept&user_id=<%=inbox.getUser_id()%>'"
           type="submit">
    <input name="refuse" value="拒绝"
           onclick="ref();window.location.href='<%=request.getContextPath()%>/requestAdd?state=refuse&user_id=<%=inbox.getUser_id()%>'"
           type="submit">
</div>
<hr>
<%
} else if ("praise".equals(inbox.getWay())) {
%>
<div style="text-align: center">
    <%=inbox.getName()%><%=inbox.getSex()%>:给你的纸条:<%=inbox.getContent()%>点赞了<br>
    <input name="thanks" value="谢谢他" type="submit"
           onclick="thanks();window.location.href='<%=request.getContextPath()%>/requestAdd?state=thank&user_id=<%=inbox.getUser_id()%>'">
</div>
<hr>
<%
} else if ("thank".equals(inbox.getWay())) {
%>
<div style="text-align: center">
    <%=inbox.getName()%><%=inbox.getSex()%>感谢你的点赞<br>
    <input name="know" value="知道了" type="submit"
           onclick="window.location.href='<%=request.getContextPath()%>/requestAdd?state=know&user_id=<%=inbox.getUser_id()%>'">
</div>
<hr>

<%
} else if ("message".equals(inbox.getWay())) {
%>
<div style="text-align: center">
    <%=inbox.getName()%><%=inbox.getSex()%>给你发了信息
    <button onclick="window.location.href='<%=request.getContextPath()%>/chatFriends?user_id=<%=inbox.getUser_id()%>'">
        前往聊天
    </button>
</div>
<hr>
<%
} else if ("note".equals(inbox.getWay())) {
%>
<div style="text-align: center">
    <%=inbox.getName()%><%=inbox.getSex()%>应用了你的纸条 :<%=inbox.getContent()%>
    <button onclick="window.location.href='<%=request.getContextPath()%>/chatFriends?user_id=<%=inbox.getUser_id()%>&state=note'">
        知道了
    </button>
</div>
<hr>
<%
} else if ("freezing".equals(inbox.getWay())) {
%>
<div style="text-align: center">
    <%=inbox.getName()%><%=inbox.getSex()%>提交了解冻申请:<br>
    申请内容是：<%=inbox.getContent()%><br>
    <button onclick="window.location.href='<%=request.getContextPath()%>/applyFreezing?state=agree&target_id=<%=inbox.getUser_id()%>';apply()">同意</button>
    <button onclick="window.location.href='<%=request.getContextPath()%>/applyFreezing?state=refuse&target_id=<%=inbox.getUser_id()%>';ref()">拒绝</button>
</div>
<%

            }
        }
    }
%>
<script type="text/javascript">
    function acc() {
        alert("添加成功");
    }

    function ref() {
        alert("成功拒绝");
    }

    function thanks() {
        alert("他已经收到了你的感谢");
    }
    function apply(){
        alert("成功解冻");
    }
</script>
<style>
    body {
        background-image: url("../picture/new.jpg");
        background-repeat: no-repeat;
        background-attachment: fixed;
        background-position: center center;
        background-size: 100% 100%;
    }
</style>